package com.gopay.common.hessian;

import java.util.UUID;

import org.apache.commons.lang3.StringUtils;

/**
 * hessian发送端，产生的随机数
 * 
 * @SendHessianKey.java
 * @author yaobo
 * @2013-7-27 上午10:56:37 www.gopay.com.cn Inc.All rights reserved.
 */
public class SendHessianKey {
    private static final ThreadLocal<String> keyLocal = new ThreadLocal<String>();

    private SendHessianKey() {
    }

    public static String getInstance() {
        String key = keyLocal.get();
        if (StringUtils.isBlank(key)) {
            key = UUID.randomUUID().toString();
            keyLocal.set(key);
        }

        return key;
    }

    public static void main(String[] args) {
        String key = SendHessianKey.getInstance();
        System.out.println(key);

        key = SendHessianKey.getInstance();
        System.out.println(key);
    }

}
